//
//  ClosureOneVC.swift
//  ReviewSwift
//
//  Created by ladystyle100 on 2017/8/25.
//  Copyright © 2017年 WangXQ. All rights reserved.
//

import UIKit

class ClosureOneVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        
        
        let btn = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: self.view.bounds.width, height: 44))
        btn.center = self.view.center
        btn.backgroundColor = UIColor.orange
        btn.setTitle("跳转到Two", for: .normal)
        btn.addTarget(self, action: #selector(responds(_:)), for: .touchUpInside)
        self.view.addSubview(btn)
    }
    
    @objc private func responds(_ sender: UIButton) {
        let vc = ClosureTwoVC()
        vc.closure = self.testOne
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
    // 和闭包的参数返回值类型一直
    private func testOne(_ a: Int) -> Int {
        return 100 + a
    }
    
}
